package com.cn.wang.pool;

import java.util.Properties;

import org.apache.commons.lang.StringUtils;

import com.alibaba.druid.util.DruidPasswordCallback;

/** 
 * 数据库回调密码解密 
 *  
 * @author 
 * 
 */  
@SuppressWarnings("serial")  
public class DBPasswordCallback extends DruidPasswordCallback {  
  
    public void setProperties(Properties properties) {  
        super.setProperties(properties);  
        String password = properties.getProperty("jdbc.password");  
        if (!StringUtils.isEmpty(password)) {  
            // 解密数据库连接密码  
            String pwd = null;
			try {
				DesUtils des = new DesUtils("wangzaogen");
				pwd = des.decrypt(password);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
            
            setPassword(pwd.toCharArray());  
        }  
    }  
  
    public static void main(String[] args) throws Exception {  
                // 生成加密后的密码，放到jdbc.properties  
    	DesUtils des = new DesUtils("wangzaogen");
    }  
}
